<?php
class HelpController extends CController {
	public function actionIndex() {
		$smarty = Yii::app ()->smarty;
		$smarty->display ( "help/index.html" );
	}
	public function actionColumn() {
		$smarty = Yii::app ()->smarty;
		$msg = "";
		$pur = new Purview ( );
		if (isset ( $_POST ) && ! empty ( $_POST )) {
			$pur->title = addslashes ( $_POST ['title'] );
			$pur->path = addslashes ( $_POST ['path'] );
			$pur->pid = addslashes ( $_POST ['pid'] );
			$pur->orders = addslashes ( $_POST ['orders'] );
			if ($pur->save ())
				$msg = "添加成功";
		}
		$ret = $pur->findAll ( array (
			
			"condition" => "pid=0", 
			"order" => "orders" 
		) );
		$lists = CommonFunc::YiiobjectToArray ( $ret, "all" );
		foreach ( $lists as $key => $v ) {
			$listsall [] = $v;
			$arr = $pur->getPurByPid ( $v ['id'], 'all' );
			
			if (! empty ( $arr ))
				$listsall = array_merge ( $listsall, $arr );
		
		}
		$smarty->assign ( "listsall", $listsall );
		$smarty->assign ( "lists", $lists );
		$smarty->assign ( "msg", $msg );
		$smarty->display ( "help/column.html" );
	}
	public function actionDel() {
		$id = addslashes ( $_GET ['id'] );
		if ($id) {
			$pur = new Purview ( );
			$pur->deleteByPk ( $id );
		}
		$this->actionColumn ();
	}
	
	public function actionOpen() {
		$id = addslashes ( $_GET ['id'] );
		if ($id) {
			$pur = new Purview ( );
			$pur->updateByPk ( $id, array (
				
				"state" => 1 
			) );
		}
		$this->actionColumn ();
	}
	public function actionClose() {
		$id = addslashes ( $_GET ['id'] );
		if ($id) {
			$pur = new Purview ( );
			$pur->updateByPk ( $id, array (
				
				"state" => 0 
			) );
		}
		$this->actionColumn ();
	}
	public function actionEdit() {
		$action = addslashes ( $_POST ['tdid'] );
		$val = addslashes ( $_POST ['val'] );
		$ret = explode ( ".", $action );
		if ($val) {
			$pur = new Purview ( );
			$pur->updateByPk ( $ret [1], array (
				
				$ret [0] => $val 
			) );
		}
	}
}
?>